package com.jiayan.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jiayan.service.ProductService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;

@Controller
@RequestMapping("/product")
public class ProductController {

    @Resource
    private ProductService productService;


    @RequestMapping("/search")
    public String search(Model model, String keyword, @RequestParam(value="pnum", defaultValue = "1")Integer pnum){
         Page productListPage= productService.search(keyword,pnum);
         model.addAttribute("productPage",productListPage);
         model.addAttribute("keyword",keyword);

         return "material";

    }

    }
